package com.fs.config;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Version:1.0
 * @Description: TODO(一句话描述该类的功能)
 * @Date: 2024/9/25 22:20
 * @Author: love you qxl
 */
@SpringBootConfiguration
public class MyWebmvcConfig implements WebMvcConfigurer {
    // 解决跨域
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**") // 允许跨域访问的路径
                //.allowedOrigins("*") // 允许跨域的源
                .allowedOriginPatterns("*")
                .allowedMethods("POST", "GET", "PUT", "DELETE", "OPTIONS") // 允许的请求方式
                .maxAge(50000)  // 允许间隔时间
                .allowCredentials(true)  // 允许客户端发送cookie
                .allowedHeaders("*"); //允许携带头部信息
    }
}